home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Database / SimpleTableView-1 / EditFormatter.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  86 lines

  1. // -------------------------------------------------------------------------------------
  2. //    EditFormatter.h
  3. //  This software is without warranty of any kind.  Use at your own risk.
  4. // -------------------------------------------------------------------------------------
  5.  
  6. #import <objc/objc.h>
  7. #import <appkit/appkit.h>
  8. #import <mach/mach.h>
  9. #import <dbkit/dbkit.h>
  10. #import "DataTable.h"
  11. #import "EditFormatter.h"
  12.  
  13. // -------------------------------------------------------------------------------------
  14. // NXRect abbreviations
  15. #define    X                origin.x
  16. #define    Y                origin.y
  17. #define    W                size.width
  18. #define    H                size.height
  19.  
  20. // -------------------------------------------------------------------------------------
  21. // MyTextFieldCell
  22. @interface _MyTextFieldCell : TextFieldCell
  23. {
  24.     float        cellTextGray;
  25. }
  26. @end
  27. @implementation _MyTextFieldCell
  28. - setEditable:(BOOL)flag
  29. {
  30.     return [super setEditable:flag];
  31. }
  32. - setTextAttributes:textObj
  33. {
  34.     [super setTextAttributes:textObj];
  35.     [textObj setTextGray:cellTextGray];
  36. //    [textObj setBackgroundGray:cFlags1.bezeled ? NX_WHITE : NX_LTGRAY];
  37. //    [textObj setTextColor:NXConvertGrayToColor([self isEnabled] ? NX_BLACK : NX_DKGRAY)];
  38. //    [textObj setBackgroundColor:NXConvertGrayToColor(cFlags1.bezeled ? NX_WHITE : NX_LTGRAY)];
  39.     return textObj;
  40. }
  41. - setTextGray:(float)aGray
  42. {
  43.     cellTextGray = aGray;
  44.     return self;
  45. }
  46. @end
  47. // -------------------------------------------------------------------------------------
  48.  
  49. // -------------------------------------------------------------------------------------
  50. @implementation EditFormatter
  51. // -------------------------------------------------------------------------------------
  52.  
  53. // -------------------------------------------------------------------------------------
  54. // initialization
  55.  
  56. /* init */
  57. - init
  58. {
  59.     [super init];
  60.     [drawCell free]; // free old drawCell
  61.     drawCell = [[_MyTextFieldCell allocFromZone:[self zone]] initTextCell:NULL];
  62.     [drawCell setTextGray:NX_BLACK];
  63.     [drawCell setBezeled:NO];
  64.     [drawCell setBordered:NO];
  65.     [drawCell setBackgroundTransparent:YES];
  66.     [drawCell setEditable:NO];
  67.     return self;
  68. }
  69.  
  70. // -------------------------------------------------------------------------------------
  71. // get value
  72.  
  73. - getValueAt:(unsigned int)row :(unsigned int)col
  74.     withAttributes:(id <DBTableVectors>)ra :(id <DBTableVectors>)ca
  75.     usePositions:(BOOL)ur :(BOOL)uc;
  76. {
  77.     u_int    r = ur? row : (u_int)[ra identifier];
  78.     u_int    c = uc? col : (u_int)[ca identifier];
  79.     [super getValueAt:row:col withAttributes:ra:ca usePositions:ur:uc];
  80.     [drawCell setTextGray:([dataSource verifyValueAt:r:c]?NX_BLACK:NX_DKGRAY)];
  81.     return value;
  82. }
  83.  
  84. // -------------------------------------------------------------------------------------
  85. @end
  86.